<?php

/**
 *      [CodeJm!] Author CodeJm[codejm@163.com].
 *
 *      
 *      $Id: Items.php 2016-03-31 15:42:44 codejm $
 */

class ItemsModel extends \Core_CMode {

    public $_table = '`yaf_items`';

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'item_id' => '大件物品id', 
            'ic_id' => '大件物品分类id', 
            'item_name' => '物品名称', 
            'price' => '价格', 
            'addtime' => '添加时间',
        );
    }

    /**
     * 楠岃瘉瑙勫垯
     *
     */
    public function rules() {
        return array(
            'default'=> array(
                array('ic_id', 'required|maxlength[5]|integer'),
                array('item_name', 'required|maxlength[30]'),
                array('price', 'required|maxlength[6]'),
                array('addtime', 'required|maxlength[20]'),

            ),
            'only_add'=> array(
                array('ic_id', 'required|maxlength[5]|integer'),
                array('item_name', 'required|maxlength[30]'),
                array('price', 'required|maxlength[6]|numeric'),
                array('addtime', 'required|maxlength[20]'),

            ),
        );
    }

    /**
     * 鎵归噺鍒犻櫎
     *
     */
    public function delItemss($ids) {
        $ids_str = implode(',', $ids);
        $where = 'item_id IN ('.$ids_str.')';
        return $this->delete($where);
    }
    
    public function search($data) {
       
        if(!empty($data)){
            foreach($data as $k=>$v){
                if(empty($v)){
                    unset($data[$k]);
                }
            }
            $inId = implode(',',$data);
            $sql = 'select * from '.$this->_table.'where item_id in('.$inId.')';
            $dbconn =  $this->db->query($sql);
            $repeat = $dbconn->fetchAll(PDO::FETCH_ASSOC);
            return $repeat;
        }     

    }
}

?>
